wayland: check native surface for crossing events
authorOlivier Fourdan <ofourdan@redhat.com>
Thu, 19 Apr 2018 12:22:04 +0000 (14:22 +0200)
committerOlivier Fourdan <ofourdan@redhat.com>
Wed, 9 May 2018 15:30:34 +0000 (17:30 +0200)
commitd3885e92a7db130d9686592f58386c9080f6eed9
tree6c37a45c24e4f82c53dff2030dd07a73d08f8026
parent47872e517224264a30e4ae33a7f3c103361bb82a
wayland: check native surface for crossing events

gdk_wayland_*_grab()/ungrab() would emit crossing events which translate
as focus_in/focus_out events for keyboard.

However, the ungrab() functions compare the native toplevel as this is
what gets the Wayland pointer enter/leave events with the grab surface,
so if the grab is issued on a child gdk surface, those won't match and
we would emit more focus_out events than focus_in.

This means that a widget such as spice-gtk which issues a keyboard grab
whenever the pointer enters the surface and releases the grab when it
leaves the surface would get uneven numbers of focus_in/focus_out
events.

Also, gdk_wayland_seat_ungrab() would not emit crossing events for
keyboard devices, whereas gdk_wayland_device_ungrab() does, which adds
even more potential discrepancies between focus_in/focus_out events.

To solve this problem, introduce two new helper functions which check
the relevant native surfaces to emit crossing events when needed that
get called evenly from both gdk_wayland_seat_grab()/ungrab() and gdk
_wayland_device_grab()/ungrab() APIs.

Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=780422
Closes https://gitlab.gnome.org/GNOME/gtk/issues/792
gdk/wayland/gdkdevice-wayland.c